from routes import app
from flask import abort, render_template
from services.article_service import ArticleService


@app.route("/")
@app.route("/index")
def home_page():
    articles = ArticleService().get_articles()

    return render_template("index.html", articles=articles)


@app.route("/article/<article_id>")
def article_detail_page(article_id):
    article = ArticleService().get_article(article_id)
    if article:
        return render_template("article.html", article=article)

    abort(404)


@app.route("/about")
def about_page():
    return render_template("about.html")


@app.route("/login")
def login_page():
    return "login page"
